// Package mgmt
// @Author: Jianming Que
// @Description:
// @Version: 1.0.0
// @Date: 2021/4/19 22:24 上午
// @Copyright: MIN-Group；国家重大科技基础设施——未来网络北大实验室；深圳市信息论与未来网络重点实验室
//

const {CommandBase, ManagementModuleFibMgmt} = require("./CommandBase");
const aggregation = require('../common/aggregation')
const FibManagementActionAdd = "add"
const FibManagementActionDel = "del"
const FibManagementActionList = "list"
const FibManagementActionRegister = "register"

//////////////////////////////////////////////////////////////////////////////////////////////////////////
///// add
//////////////////////////////////////////////////////////////////////////////////////////////////////////

/**
 * FibAddCommand 表示一个添加下一跳的命令
 */
class FibAddCommand extends aggregation(CommandBase){
    constructor() {
        super();
    }
}

/**
 * CreateFibAddCommand 创建一个 FibAddCommand 命令
 * @param topPrefix
 * @param parameters
 * @return {FibAddCommand}
 */
function createFibAddCommand(topPrefix, parameters){
    let command = new FibAddCommand()
    command.setTopPrefix(topPrefix)
    command.setModuleName(ManagementModuleFibMgmt)
    command.setAction(FibManagementActionAdd)
    command.setParameters(parameters)
    return command
}


//////////////////////////////////////////////////////////////////////////////////////////////////////////
///// delete
//////////////////////////////////////////////////////////////////////////////////////////////////////////

/**
 * FibDeleteCommand 表示删除前缀指定logic face命令
 */
class FibDeleteCommand extends aggregation(CommandBase){
    constructor() {
        super();
    }
}

/**
 * CreateFibDeleteCommand 创建一个 FibDeleteCommand 命令
 * @param topPrefix
 * @param parameters
 * @return {FibDeleteCommand}
 */
function createFibDeleteCommand(topPrefix, parameters){
    let command = new FibDeleteCommand()
    command.setTopPrefix(topPrefix)
    command.setModuleName(ManagementModuleFibMgmt)
    command.setAction(FibManagementActionDel)
    command.setParameters(parameters)
    return command
}

/**
 * FibListCommand 表示删除前缀指定logic face命令
 */
class FibListCommand extends aggregation(CommandBase){
    constructor() {
        super();
    }
}

/**
 * CreateFibListCommand 创建一个 FibListCommand 命令
 * @param topPrefix
 * @param parameters
 * @return {FibListCommand}
 */
function createFibListCommand(topPrefix, parameters){
    let command = new FibListCommand()
    command.setTopPrefix(topPrefix)
    command.setModuleName(ManagementModuleFibMgmt)
    command.setAction(FibManagementActionList)
    command.setParameters(parameters)
    return command
}

/**
 * RegisterPrefixCommand 注册一个前缀监听的命令
 */
class RegisterPrefixCommand extends aggregation(CommandBase){
    constructor() {
        super();
    }
}

/**
 * CreateRegisterPrefixCommand 创建一个 RegisterPrefixCommand 命令
 * @param topPrefix
 * @param parameters
 * @return {RegisterPrefixCommand}
 */
function createRegisterPrefixCommand(topPrefix, parameters){
    let command = new RegisterPrefixCommand()
    command.setTopPrefix(topPrefix)
    command.setModuleName(ManagementModuleFibMgmt)
    command.setAction(FibManagementActionRegister)
    command.setParameters(parameters)
    return command
}

module.exports = {
    FibAddCommand: FibAddCommand,
    FibListCommand: FibListCommand,
    FibDeleteCommand: FibDeleteCommand,
    RegisterPrefixCommand: RegisterPrefixCommand,
    FibManagementActionAdd: FibManagementActionAdd,
    FibManagementActionDel: FibManagementActionDel,
    FibManagementActionList: FibManagementActionList,
    FibManagementActionRegister: FibManagementActionRegister,
    createFibAddCommand: createFibAddCommand,
    createFibListCommand: createFibListCommand,
    createFibDeleteCommand: createFibDeleteCommand,
    createRegisterPrefixCommand: createRegisterPrefixCommand
}